package com.kha.listone.util;

import java.util.Calendar;
import java.util.Date;
import java.util.Vector;

import com.kha.listone.common.model.SettingsModel;
import com.kha.listone.locale.LocaleConstants;

public class Globals {
	public static String APP_LOCALE = LocaleConstants.locales.EN;

	public static boolean HAVE_DROPBOX = false;

	public static final String TAG_TASKLIST = "tasks";
	public static final String TAG_TASK = "task";
	public static final String TAG_TASKNAME = "name";
	public static final String TAG_TASKDUE = "duedate";
	public static final String TAG_TASKRECURRENCE = "recurrence";
	public static final String TAG_TASKIMPORTANT = "important";
	public static final String TAG_TASKDAYRECURRENCE = "dayrecurrence";
	public static final String TAG_TASKDEADLINE = "deadline";
	public static final String TAG_TASKNOTE = "note";
	public static final String TAG_TASKTAG = "tag";
	public static final String TAG_TASKDONE = "done";

	public static final String XML_TASKLIST_FILE_PATH = System
			.getProperty("fileconn.dir.private") + "Tasks.xml";
	public static final String UPDATED_FILE_PATH = System
			.getProperty("fileconn.dir.private") + "Update";

	public static final String XML_SETTINGS_FILE_PATH = System
			.getProperty("fileconn.dir.private") + "Settings.xml";

	public static final String TAG_SETTINGS = "settings";

	public static final String TAG_SETTING_DATEFORMAT = "dateformat";

	public static final String TAG_SETTING_LANGUAGE = "language";

	public static final String TAG_SETTING_SYNCTIME = "synctime";

	public static final String TAG_HAVE_DROPBOX = "dropbox";
	
	public static final String TAG_DROPBOX_USERNAME = "username";
	public static final String TAG_DROPBOX_PASSWORD = "password";

	public static final int MAX_STACK = 5;

	public static String DROPBOX_USERNAME = "username";

	public static String DROPBOX_PASSWORD = "password";
	
	public static SettingsModel settingListOne;
	
	public static Vector taskList;

	public static boolean isTodayTask(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		int day, month, year, dayNow, monthNow, yearNow;
		day = cal.get(Calendar.DAY_OF_MONTH);
		month = cal.get(Calendar.MONTH);
		year = cal.get(Calendar.YEAR);
		Date now = new Date();
		cal.setTime(now);
		dayNow = cal.get(Calendar.DAY_OF_MONTH);
		monthNow = cal.get(Calendar.MONTH);
		yearNow = cal.get(Calendar.YEAR);

		if (day != dayNow || month != monthNow || year != yearNow) {
			return false;
		}
		return true;
	}

	public static boolean isDayEqual(Date date1, Date date2) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date1);
		int day, month, year, dayNow, monthNow, yearNow;
		day = cal.get(Calendar.DAY_OF_MONTH);
		month = cal.get(Calendar.MONTH);
		year = cal.get(Calendar.YEAR);

		cal.setTime(date2);
		dayNow = cal.get(Calendar.DAY_OF_MONTH);
		monthNow = cal.get(Calendar.MONTH);
		yearNow = cal.get(Calendar.YEAR);

		if (day != dayNow || month != monthNow || year != yearNow) {
			return false;
		}
		return true;
	}

	public static boolean isDayGreater(Date date1, Date date2) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date1);
		int day, month, year, dayNow, monthNow, yearNow;
		day = cal.get(Calendar.DAY_OF_MONTH);
		month = cal.get(Calendar.MONTH);
		year = cal.get(Calendar.YEAR);

		cal.setTime(date2);
		dayNow = cal.get(Calendar.DAY_OF_MONTH);
		monthNow = cal.get(Calendar.MONTH);
		yearNow = cal.get(Calendar.YEAR);

		if (year > yearNow || (year == yearNow && month > monthNow)
				|| (year == yearNow && month == monthNow && day > dayNow)) {

			return true;
		}
		return false;
	}

}
